#include "comm.hpp"
#include <unistd.h>

int main()
{
    key_t k = getKey();
    printf("0x%x\n",k);
    int shmid = creatShm(k);
    printf("shmid : %d\n",shmid);

    sleep(5);

    char *start = (char*)attachShm(shmid);  //挂接成功
    printf("attach success, addrees start: %p\n",start);

    // 使用
    while(true)
    {
        // char buffer[]
        printf("server say: %s\n",start);
        sleep(1);
    }

    // 去关联
    detachShm(start);
    
    sleep(5);

    // 删除共享内存
    delShm(shmid);
    return 0;
}